#include <memory>
#include "UdpServer.hpp"
#include "Dict.hpp"
#include "InetAddr.hpp"

// 用来做测试的！
std::string default_handler(const std::string& msg){
    std::string s = "Server Get -> ";
    s += msg;
    return s;
}


//现在来写第二个版本 -> 翻译server系统

// ./UDP_SERVER.exe  port
int main(int argc, char* argv[]){
    if(argc != 2){
        std::cerr << "please usage : " << "./UDP_SERVER  port" << std::endl;
        return 1;
    }

    int port = std::stoi(std::string(argv[1]));
    
    Dict dict;
    //dict.Print();

    std::unique_ptr<UdpServer> Pserver = std::make_unique<UdpServer>(port, 
        [&dict](const std::string& word, const InetAddr& client)->std::string{return dict.Translate(word, client);}
    );

    Pserver->Init();
    Pserver->Start();

    return 0;
}